from selenium.webdriver.common.by import By
from time import sleep
from Unit_10.Page.Page1 import Page1

class Page2(Page1):
    # 定位器
    # 1 我的酒仙的定位
    jiuxian_loc = (By.XPATH,'/html/body/div[2]/div/div[2]/ul/li[1]/div[1]/a')
    # 3 收货地址定位
    address_loc = (By.XPATH,'/html/body/div[4]/div[1]/div[2]/div[4]/a[3]/span')
    # 4 添加新地址定位
    add_address_loc = (By.CLASS_NAME,'addressTrue')
    # 5 收货人定位
    people_loc = (By.ID,'people')
    # 6 select 省定位
    province_loc = (By.ID,'province')
    # 7 select 市定位
    city_loc = (By.ID,'city')
    # 8 select 区定位
    district_loc = (By.ID,'district')
    # 9 详细地址定位
    address_text_loc = (By.ID,'address')
    # 10 手机号定位
    phone_loc = (By.ID,'iphone')
    # 11 提交定位
    save_loc = (By.ID,'save')
    # 12 提交的确定定位
    save_sure_loc = (By.XPATH,'/html/body/div[8]/div/div[3]/span[1]')

    # 方法封装
    # 1 我的酒仙
    def jiuxian(self):
        self.click(self.jiuxian_loc)
    # 2 收货地址
    def address(self):
        self.click(self.address_loc)
    # 3 添加新地址
    def add_address(self):
        self.click(self.add_address_loc)
    # 4 收货人
    def people(self):
        self.send_keys(self.people_loc,'小小怪上将')
    # 4 select 省
    def province(self):
        self.select_index(self.province_loc,1)
    # 4 select 市
    def city(self):
        self.select_value(self.city_loc,'52')
    # 4 select 区
    def district(self):
        self.select_text(self.district_loc,'昌平区')
    # 4 详细地址
    def address_text(self):
        self.send_keys(self.address_text_loc,'南口南大街100号')
    # 4 手机号
    def phone(self):
        self.send_keys(self.phone_loc,'13381144084')
    # 4 点击提交
    def save(self):
        self.click(self.save_loc)
    # 5 确定
    def save_sure(self):
        self.click(self.save_sure_loc)

    def jiuxian_luoji2(self):
        self.jiuxian_luoji1()
        self.jiuxian()
        self.new_window()
        self.scroll_x(800)
        self.address()
        self.add_address()
        self.people()
        self.province()
        self.city()
        self.district()
        self.address_text()
        self.phone()
        self.save()
        self.save_sure()


